package com.zzk.protect.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzk.protect.pojo.ConstantItem;
import com.zzk.protect.pojo.ConstantType;
import com.zzk.protect.service.ConstantItemService;
import com.zzk.protect.mapper.ConstantItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 周振坤
* @description 针对表【constant_item】的数据库操作Service实现
* @createDate 2025-06-25 17:43:31
*/
@Service
public class ConstantItemServiceImpl extends ServiceImpl<ConstantItemMapper, ConstantItem>
    implements ConstantItemService{
    @Autowired
    private ConstantItemMapper constantItemMapper;

    @Override
    public List<ConstantItem> selectByIdOrName(Object param) {
            QueryWrapper<ConstantItem> wrapper = new QueryWrapper<>();

        if (param instanceof Integer) {
            wrapper.eq("id", param);
        } else if (param instanceof String) {
            wrapper.like("name", param);
            } else {
                throw new IllegalArgumentException("参数类型必须是Long或String");
            }
            return constantItemMapper.selectList(wrapper);
        }
    }





